package com.example.demo;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class User {
    private String userName;
    private String userPass;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPass() {
        return userPass;
    }

    public void setUserPass(String userPass) {
        this.userPass = userPass;
    }
    public boolean isValidate(){
        String sql = "select * from UserInfo where userName=? and userPwd=?";
        Connection conn = null;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        try{
            conn  = ConnBean.getConn();
            pstmt = conn.prepareStatement(sql);
            pstmt.setString(1,this.userName);
            pstmt.setString(2,this.userPass);

            rs = pstmt.executeQuery();
            if (rs.next()){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            ConnBean.closeDB(rs,pstmt,conn);
        }
        return false;
    }

}